//
//  HEOcrManage.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/11/19.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEOcrManage.h"

@interface HEOcrManage ()
 
@property (nonatomic,strong)NSString *appid ;
@property (nonatomic,strong)NSString *nonce ;
@property (nonatomic,strong)NSString *userID;
@property (nonatomic,strong)NSString *sign;
@property (nonatomic,strong)NSString *orderNo;
@property (nonatomic,strong)NSString *LICENCE;

@end

@implementation HEOcrManage

+ (instancetype)sharedClient {
    static HEOcrManage *_sharedClient = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _sharedClient = [[HEOcrManage alloc] init];
    });
    return _sharedClient;
}
//
//- (void)startServiceWithType:(WBOCRSDKType)type {
//    
//    
//    //    self.userID = [NSString stringWithFormat:@"userID%llu", mach_absolute_time()];
//    self.userID = [UserManager sharedUserManager].curUserInfo.id;
//    self.nonce = [DYTools createUuid];
//    self.orderNo = [DYTools createUuid];
//
//    // 测试
////    self.appid = @"TIDAQrFk";
////    self.LICENCE = @"N+RTcoohAUJTxGa505RXhUMWmKEOp8ehmTn58TcR8RDTOWl1MHNmPtM6YVnqxB0r+JXY4Th8sEs1DM4ARosx2eoJ8TVTtB1sNcsgz0hD90MzIiHkN6jVyUZc5Wg3tKzMIeDk2U6s2yXjD0//C8cDjY4f5qWFs8uNwTVRHYwwLKoVeLix9ZqGAXJg/Uf2HN7M7oaBkNDu0KRLhyTkbGi+prnPV7jKek4xsXFtAdec9y0lHMmp0Owh1NNvwdrO30Oehj+veDpOAIwG2iMIQYhl3PmktJPyRsdi0G9fKeCw5ZFz8AEuJ671n4PCJIx10rMDG/Zl3BU3LYhJePVCVTutzA==";
//        
//        // 正式
//    self.appid = @"IDAZYz7E";
//    self.LICENCE = @"N+RTcoohAUJTxGa505RXhUMWmKEOp8ehmTn58TcR8RDTOWl1MHNmPtM6YVnqxB0r+JXY4Th8sEs1DM4ARosx2eoJ8TVTtB1sNcsgz0hD90MzIiHkN6jVyUZc5Wg3tKzMIeDk2U6s2yXjD0//C8cDjY4f5qWFs8uNwTVRHYwwLKp9uabLXsuievZzv+IJDIbRBz3ReByiCUEM4GVIQSnGIV25+8gsQAOYgBcXSZhSP1ZaAyjHs9lpbWjDFXkNV7cEqjrnKwIxsYIFfx6AspzpP/kK9lb9FaukCCxX2PQlq9V6eHJd56z20bjTuRBVdWgQiXgdP77DyPL5XywbxLS8eg==";
//    
//    
//    WBOCRConfig *config = [WBOCRConfig sharedConfig];
//    config.SDKType = type; // 身份证两面识别
//    /// 模拟拉取签名地址，合作方接入时，找自己后台拉取
//    config.needRecordVideo = NO;
//    
// 
//    NSDictionary *params = @{@"appid":self.appid, @"id":self.userID,@"nonce":self.nonce};
//    __weak typeof(self) weakSelf = self;
//
//    [WOAFNetWorkingHandle POSTWithBaseUrlByKeyValue:KServerUrl suffixUrl:KgetWeChatSign parameters:params success:^(id  _Nonnull responseObject) {
//        HEObjectDataResponse *response = [HEObjectDataResponse mj_objectWithKeyValues:responseObject];
//        weakSelf.sign = response.data;
//         
//        [[Dialog Instance] showCenterProgressWithLabel:@"加载中..."];
//
//        /** SDK服务拉起 */
//        [[WBOCRService sharedService] startOCRServiceWithConfig:[WBOCRConfig sharedConfig]
//                                                        version:@"1.0.0"
//                                                          appId:self.appid
//                                                          nonce:self.nonce
//                                                         userId:self.userID
//                                                           sign:self.sign
//                                                        orderNo:self.orderNo
//                                                   startSucceed:^{
//                                                       /** SDK服务拉起成功回调 */
//                                                       DLog(@"启动SDK成功！！！");
//                                                        [[Dialog Instance] hideHUD];
//
//                                                   }recognizeSucceed:^(id _Nonnull resultInfoModel,id extension) {
//                                                       /** SDK本次识别成功回调 */
//                                                       if ([self.delegate respondsToSelector:@selector(ocrResult:)]) {
//                                                           [self.delegate ocrResult: resultInfoModel];
//                                                       }
//                                                       DLog(@"SDK识别成功！！！");
//                                                    }failed:^(NSError * _Nonnull error,id extension) {
//                                                       /** SDK异常回调 */
//                                                       [[Dialog Instance] hideHUD];
//                                                        
//                                                        if (error.code == 200101) {
//                                                            [Dialog toastBottom:@"已取消认证"];
//                                                            if ([self.delegate respondsToSelector:@selector(ocrCancel)]) {
//                                                                [self.delegate ocrCancel];
//                                                            }
//                                                        }else {
//                                                            [Dialog toastBottom:@"识别失败"];
//                                                            DLog(@"error:%@",error);
//                                                        }
//                                                   }];
//        
//    } failure:^(NSError * _Nonnull error) {
//    }]; 
//}
//
//
//- (void)showResultPage:(id)resultModel{
// 
//    
//    if ([[WBOCRConfig sharedConfig] SDKType] == WBOCRSDKTypeBankCard) {
//        /// =====================> 银行卡识别结果
//        WBBankCardInfoModel *bankCardInfo = (WBBankCardInfoModel *)resultModel;
//        
//    }else if ([[WBOCRConfig sharedConfig] SDKType] == WBOCRSDKTypeIDCardNormal){
//        /// =====================> 身份证两面识别结果
//        WBIDCardInfoModel *resultInfoModel = (WBIDCardInfoModel *)resultModel;
//        
//    }else if ([[WBOCRConfig sharedConfig] SDKType] == WBOCRSDKTypeIDCardFrontSide){
//        /// =====================> 身份证人像面识别结果
//        WBIDCardInfoModel *resultInfoModel = (WBIDCardInfoModel *)resultModel;
//        
//    }else if ([[WBOCRConfig sharedConfig] SDKType] == WBOCRSDKTypeIDCardBackSide){
//        /// =====================> 身份证识国徽面别结果
//        WBIDCardInfoModel *resultInfoModel = (WBIDCardInfoModel *)resultModel;
//    }else if ([[WBOCRConfig sharedConfig] SDKType] == WBOCRSDKTypeVehicleLicenseNormal){
//        /// =====================> 行驶证两面识别结果
//        WBVehicleLicenseModel *vehicleModel = (WBVehicleLicenseModel *)resultModel;
//    }else if ([[WBOCRConfig sharedConfig] SDKType] == WBOCRSDKTypeVehicleLicenseHomePage){
//        /// =====================> 行驶证正本识别结果
//        WBVehicleLicenseModel *vehicleModel = (WBVehicleLicenseModel *)resultModel;
//    }else if ([[WBOCRConfig sharedConfig] SDKType] == WBOCRSDKTypeVehicleLicenseSecondaryPage){
//        /// =====================>  行驶证副本识别结果
//        WBVehicleLicenseModel *vehicleModel = (WBVehicleLicenseModel *)resultModel;
//    }else if ([[WBOCRConfig sharedConfig] SDKType] == WBOCRSDKTypeDriverLicense){
//        /// =====================> 驾驶证识别结果
//        WBDriverLicenseModel *driverLicenceModel = (WBDriverLicenseModel *)resultModel;
//    }
//    
//}
//
// 
//#pragma mark - 图片编码和压缩方法
///**
// @des 如果第三方用户，有将识别的图片上传后台存档的需求，可以调用此方法
// 
// UIImageJPEGRepresentation 的第一个参数表示ocr识别完成后，回传的UIImage对象
// 第二个参数scale表示压缩率，建议值是0.9
// 经过测试，ocr返回的图片，JPEG编码，压缩率为0.9的情况下，大小小于800KB
// 
// @return 图片经过JPEG编码后的二进制对象
// */
//- (NSData *)dataWithImage:(UIImage *)img{
//    return UIImageJPEGRepresentation(img, 0.9);
//}

@end
